var cs;    //画布
var dx, dy;        //draw X, Y
var i, j, t, a;           //t = times
var pn = [];     //225  pn  0=" " , 1=black , 2=white
var n;                // 225 棋子编码号
var px, py;        // piece x,y
var dn, dn1;        //下子计数
var isDo;      //游戏操作控制 1=可下子，0=不可下
var B, W, k;   //detect win Black White
var cordp, cordp1;   //record pn & G9
var cord;        //record switch
var mode;      //0=人人，1=人机
var wn;
var sn;
var dwn = [];    // 120 记录，下子60回合120子为和棋
var col, row;
var cn, kn;      //show record num
var gn;    //game round number
var fudat = [];      // 200 复盘数据
var fusum;    //复盘记录总数
var sd;         //复盘
var jqn = [];      // 255 计权数
var jqf, jqfn;        //计权分，优选点位码
var js = [];         //255禁手设置
var jsset;    //s8 show restrict mark

// https://blog.csdn.net/baidu_41801770/article/details/128178384

function testAIq() {
    //人机对战AI选子，加权计算
    for (i = 1; i <= 225; i++) {
        jqn[i] = 0;
    }      //scan init
    //遍历加权
    for (i = 1; i <= 15; i++) {    //遍历scan B & W 子
        for (j = 1; j <= 15; j++) {
            k = (i - 1) * 15 + j;    //pn(n) number
            //独子 左右上下 二对角 八方
            if (pn[k] == 2) {
                if (pn[k - 1] == 0) jqn[k - 1] = jqn[k - 1] + 20;
                if (pn[k + 1] == 0) jqn[k + 1] = jqn[k + 1] + 20;
                if (pn[k - 15] == 0) jqn[k - 15] = jqn[k - 15] + 20;
                if (pn[k + 15] == 0) jqn[k + 15] = jqn[k + 15] + 20;
                if (pn[k + 14] == 0) jqn[k + 14] = jqn[k + 14] + 20;
                if (pn[k + 16] == 0) jqn[k + 16] = jqn[k + 16] + 20;
                if (pn[k - 14] == 0) jqn[k - 14] = jqn[k - 14] + 20;
                if (pn[k - 16] == 0) jqn[k - 16] = jqn[k - 16] + 20;
            }//pn
            //连二
            if (pn[k] == 2 && pn[k + 1] == 2) {  //左右
                if (pn[k - 1] == 0) jqn[k - 1] = jqn[k - 1] + 520;
                if (pn[k + 2] == 0) jqn[k + 2] = jqn[k + 2] + 520;
            }



            if (pn[k] == 2 && pn[k + 15] == 2) {  //上下
                if (pn[k - 15] == 0) jqn[k - 15] = jqn[k - 15] + 520;
                if (pn[k + 30] == 0) jqn[k + 30] = jqn[k + 30] + 520;
            }

            if (pn[k] == 2 && pn[k + 14] == 2) {  //左对角
                if (pn[k - 14] == 0) jqn[k - 14] = jqn[k - 14] + 520;
                if (pn[k + 28] == 0) jqn[k + 28] = jqn[k + 28] + 520;
            }

            if (pn[k] == 2 && pn[k + 16] == 2) {   //右对角
                if (pn[k - 16] == 0) jqn[k - 16] = jqn[k - 16] + 520;
                if (pn[k + 32] == 0) jqn[k + 32] = jqn[k + 32] + 520;
            }

            //嵌三   02020    +1020 为活三冲四进攻点
            if (pn[k] == 2 && pn[k + 1] == 0 && pn[k + 2] == 2) {  //左右
                jqn[k + 1] = jqn[k + 1] + 520;
                if (pn[k - 1] == 0) jqn[k - 1] = jqn[k - 1] + 1020;
                if (pn[k + 3] == 0) jqn[k + 3] = jqn[k + 3] + 1020;
            }

            if (pn[k] == 2 && pn[k + 15] == 0 && pn[k + 30] == 2) {  //上下
                jqn[k + 15] = jqn[k + 15] + 520;
                if (pn[k - 15] == 0) jqn[k - 15] = jqn[k - 15] + 1020;
                if (pn[k + 45] == 0) jqn[k + 45] = jqn[k + 45] + 1020;
            }

            if (pn[k] == 2 && pn[k - 14] == 0 && pn[k - 28] == 2) {//左对角
                jqn[k - 14] = jqn[k - 14] + 520;
                if (pn[k + 14] == 0) jqn[k + 14] = jqn[k + 14] + 1020;
                if (pn[k - 42] == 0) jqn[k - 42] = jqn[k - 42] + 1020;
            }

            if (pn[k] == 2 && pn[k + 16] == 0 && pn[k + 32] == 2) {//右对角
                jqn[k + 16] = jqn[k + 16] + 520;
                if (pn[k - 16] == 0) jqn[k - 16] = jqn[k - 16] + 1020;
                if (pn[k + 48] == 0) jqn[k + 48] = jqn[k + 48] + 1020;
            }

            //三连，眠三抢冲四  12220  02221
            if (pn[k] == 2 && pn[k + 1] == 2 && pn[k + 2] == 2) {  //左右
                if (pn[k - 1] == 0) jqn[k - 1] = jqn[k - 1] + 2320;
                if (pn[k + 3] == 0) jqn[k + 3] = jqn[k + 3] + 2320;
            }
            if (pn[k] == 2 && pn[k + 15] == 2 && pn[k + 30] == 2) {  //上下
                if (pn[k - 15] == 0) jqn[k - 15] = jqn[k - 15] + 2320;
                if (pn[k + 45] == 0) jqn[k + 45] = jqn[k + 45] + 2320;
            }
            if (pn[k] == 2 && pn[k - 14] == 2 && pn[k - 28] == 2) {//左对角
                if (pn[k + 14] == 0) jqn[k + 14] = jqn[k + 14] + 2320;
                if (pn[k - 42] == 0) jqn[k - 42] = jqn[k - 42] + 2320;
            }
            if (pn[k] == 2 && pn[k + 16] == 2 && pn[k + 32] == 2) {//右对角
                if (pn[k - 16] == 0) jqn[k - 16] = jqn[k - 16] + 2320;
                if (pn[k + 48] == 0) jqn[k + 48] = jqn[k + 48] + 2320;
            }

            //三连，活三变活四，必杀  0022200    +2000
            if (pn[k - 2] == 0 && pn[k - 1] == 0 && pn[k] == 2 && pn[k + 1] == 2 && pn[k + 2] == 2 && pn[k + 3] == 0 && pn[k + 4] == 0) {  //左右
                jqn[k - 1] = jqn[k - 1] + 3500;
                jqn[k + 3] = jqn[k + 3] + 3500;
            }

            if (pn[k - 30] == 0 && pn[k - 15] == 0 && pn[k] == 2 && pn[k + 15] == 2 && pn[k + 30] == 2 && pn[k + 45] == 0 && pn[k + 60] == 0) {  //上下
                jqn[k - 15] = jqn[k - 15] + 3500;
                jqn[k + 45] = jqn[k + 45] + 3500;
            }

            if (pn[k - 28] == 0 && pn[k - 14] == 0 && pn[k] == 2 && pn[k + 14] == 2 && pn[k + 28] == 2 && pn[k + 42] == 0 && pn[k + 56] == 0) {//左对角
                jqn[k - 14] = jqn[k - 14] + 3500;
                jqn[k + 42] = jqn[k + 42] + 3500;
            }

            if (pn[k - 32] == 0 && pn[k - 16] == 0 && pn[k] == 2 && pn[k + 16] == 2 && pn[k + 32] == 2 && pn[k + 48] == 0 && pn[k + 64] == 0) {//右对角
                jqn[k - 16] = jqn[k - 16] + 3500;
                jqn[k + 48] = jqn[k + 48] + 3500;
            }
            //*********
            //白子算杀，做杀，找活三嵌四交点 +2500

            //嵌四类 做冲四 2022  2202   布杀点 +1800
            // 120220  122020 020221 022021
            if (j < 12) {
                if (pn[k] == 2 && pn[k + 1] == 0 && pn[k + 2] == 2 && pn[k + 3] == 2) {  //左右
                    if (pn[k - 1] == 0 || pn[k + 4] == 0) { jqn[k + 1] = jqn[k + 1] + 1800; }
                }
                if (pn[k] == 2 && pn[k + 1] == 2 && pn[k + 2] == 0 && pn[k + 3] == 2) {  //左右
                    if (pn[k - 1] == 0 || pn[k + 4] == 0) { jqn[k + 2] = jqn[k + 2] + 1800; }
                }
            } //j<12

            if (i < 12) {
                if (pn[k] == 2 && pn[k + 15] == 0 && pn[k + 30] == 2 && pn[k + 45] == 2) {  //上下
                    if (pn[k - 15] == 0 || pn[k + 60] == 0) { jqn[k + 15] = jqn[k + 15] + 1800; }
                }
                if (pn[k] == 2 && pn[k + 15] == 2 && pn[k + 30] == 0 && pn[k + 45] == 2) {  //上下
                    if (pn[k - 15] == 0 || pn[k + 60] == 0) { jqn[k + 30] = jqn[k + 30] + 1800; }
                }
            } //i<12

            if (j > 4 && i < 12) {
                if (pn[k] == 2 && pn[k + 14] == 0 && pn[k + 28] == 2 && pn[k + 42] == 2) {  //斜左
                    if (pn[k - 14] == 0 || pn[k + 56] == 0) { jqn[k + 14] = jqn[k + 14] + 1800; }
                }
                if (pn[k] == 2 && pn[k + 14] == 2 && pn[k + 28] == 0 && pn[k + 42] == 2) {  //斜左
                    if (pn[k - 14] == 0 || pn[k + 56] == 0) { jqn[k + 28] = jqn[k + 28] + 1800; }
                }
            } //j>4, i<12

            if (j < 12 && i < 12) {
                if (pn[k] == 2 && pn[k + 16] == 0 && pn[k + 32] == 2 && pn[k + 48] == 2) {  //右斜
                    if (pn[k - 16] == 0 || pn[k + 64] == 0) { jqn[k + 16] = jqn[k + 16] + 1800; }
                }
                if (pn[k] == 2 && pn[k + 16] == 2 && pn[k + 32] == 0 && pn[k + 48] == 2) {  //右斜
                    if (pn[k - 16] == 0 || pn[k + 64] == 0) { jqn[k + 32] = jqn[k + 32] + 1800; }
                }
            } //i<12&&j<12

            //嵌四 020220  022020  必杀点+3500  j<12  防越界
            if (j < 12) {
                if (pn[k - 1] == 0 && pn[k] == 2 && pn[k + 1] == 0 && pn[k + 2] == 2 && pn[k + 3] == 2 && pn[k + 4] == 0) {  //左右
                    jqn[k + 1] = jqn[k + 1] + 3500;
                }
                if (pn[k - 1] == 0 && pn[k] == 2 && pn[k + 1] == 2 && pn[k + 2] == 0 && pn[k + 3] == 2 && pn[k + 4] == 0) {  //左右
                    jqn[k + 2] = jqn[k + 2] + 3500;
                }
            }

            if (i < 12) {
                if (pn[k - 15] == 0 && pn[k] == 2 && pn[k + 15] == 0 && pn[k + 30] == 2 && pn[k + 45] == 2 && pn[k + 60] == 0) {  //上下
                    jqn[k + 15] = jqn[k + 15] + 3500;
                }
                if (pn[k - 15] == 0 && pn[k] == 2 && pn[k + 15] == 2 && pn[k + 30] == 0 && pn[k + 45] == 2 && pn[k + 60] == 0) {  //上下
                    jqn[k + 30] = jqn[k + 30] + 3500;
                }
            }

            if (j > 4 && i < 12) {
                if (pn[k - 14] == 0 && pn[k] == 2 && pn[k + 14] == 0 && pn[k + 28] == 2 && pn[k + 42] == 2 && pn[k + 56] == 0) {  //斜左
                    jqn[k + 14] = jqn[k + 14] + 3500;
                }
                if (pn[k - 14] == 0 && pn[k] == 2 && pn[k + 14] == 2 && pn[k + 28] == 0 && pn[k + 42] == 2 && pn[k + 56] == 0) {  //斜左
                    jqn[k + 28] = jqn[k + 28] + 3500;
                }
            }

            if (j < 12 && i < 12) {
                if (pn[k - 16] == 0 && pn[k] == 2 && pn[k + 16] == 0 && pn[k + 32] == 2 && pn[k + 48] == 2 && pn[k + 64] == 0) {  //右斜
                    jqn[k + 16] = jqn[k + 16] + 3500;
                }
                if (pn[k - 16] == 0 && pn[k] == 2 && pn[k + 16] == 2 && pn[k + 32] == 0 && pn[k + 48] == 2 && pn[k + 64] == 0) {  //右斜
                    jqn[k + 32] = jqn[k + 32] + 3500;
                }
            }

            //活四冲四 022220  122220  022221   
            //此是必杀点  +9000  j<12  防越界
            if (pn[k] == 2 && pn[k + 1] == 2 && pn[k + 2] == 2 && pn[k + 3] == 2) {  //左右
                if (j > 1 && pn[k - 1] == 0) jqn[k - 1] = jqn[k - 1] + 9000;
                if (j < 12 && pn[k + 4] == 0) jqn[k + 4] = jqn[k + 4] + 9000;
            }

            if (pn[k] == 2 && pn[k + 15] == 2 && pn[k + 30] == 2 && pn[k + 45] == 2) {  //上下
                if (i > 1 && pn[k - 15] == 0) jqn[k - 15] = jqn[k - 15] + 9000;
                if (i < 12 && pn[k + 60] == 0) jqn[k + 60] = jqn[k + 60] + 9000;
            }

            if (pn[k] == 2 && pn[k + 14] == 2 && pn[k + 28] == 2 && pn[k + 42] == 2) {//左对角
                if (i > 4 && j < 14 && pn[k - 14] == 0) jqn[k - 14] = jqn[k - 14] + 9000;
                if (i < 12 && j > 4 && pn[k + 56] == 0) jqn[k + 56] = jqn[k + 56] + 9000;
            }

            if (pn[k] == 2 && pn[k + 16] == 2 && pn[k + 32] == 2 && pn[k + 48] == 2) {//右对角     
                if (j > 1 && i < 12 && pn[k - 16] == 0) jqn[k - 16] = jqn[k - 16] + 9000;
                if (j < 12 && i < 12 && pn[k + 64] == 0) jqn[k + 64] = jqn[k + 64] + 9000;
            }

            //嵌五，此是必杀点 20222  22022  22202 +9000
            if (j < 12) {      // j<12  防越界
                if (pn[k] == 2 && pn[k + 1] == 0 && pn[k + 2] == 2 && pn[k + 3] == 2 && pn[k + 4] == 2) {  //左右 20222
                    jqn[k + 1] = jqn[k + 1] + 9000;
                }
                if (pn[k] == 2 && pn[k + 1] == 2 && pn[k + 2] == 0 && pn[k + 3] == 2 && pn[k + 4] == 2) {  //左右 22022
                    jqn[k + 2] = jqn[k + 2] + 9000;
                }
                if (pn[k] == 2 && pn[k + 1] == 2 && pn[k + 2] == 2 && pn[k + 3] == 0 && pn[k + 4] == 2) {  //左右 22202
                    jqn[k + 3] = jqn[k + 3] + 9000;
                }
            }  //j<12

            if (i < 12) {
                if (pn[k] == 2 && pn[k + 15] == 0 && pn[k + 30] == 2 && pn[k + 45] == 2 && pn[k + 60] == 2) {  //上下 20222
                    jqn[k + 15] = jqn[k + 15] + 9000;
                }
                if (pn[k] == 2 && pn[k + 15] == 2 && pn[k + 30] == 0 && pn[k + 45] == 2 && pn[k + 60] == 2) {  //上下 22022
                    jqn[k + 30] = jqn[k + 30] + 9000;
                }
                if (pn[k] == 2 && pn[k + 15] == 2 && pn[k + 30] == 2 && pn[k + 45] == 0 && pn[k + 60] == 2) {  //上下 22202
                    jqn[k + 45] = jqn[k + 45] + 9000;
                }
            }  //i<12

            if (j > 4 && i < 12) {
                if (pn[k] == 2 && pn[k + 14] == 0 && pn[k + 28] == 2 && pn[k + 42] == 2 && pn[k + 56] == 2) {  //斜左 20222
                    jqn[k + 14] = jqn[k + 14] + 9000;
                }
                if (pn[k] == 2 && pn[k + 14] == 2 && pn[k + 28] == 0 && pn[k + 42] == 2 && pn[k + 56] == 2) {  //斜左 22022
                    jqn[k + 28] = jqn[k + 28] + 9000;
                }
                if (pn[k] == 2 && pn[k + 14] == 2 && pn[k + 28] == 2 && pn[k + 42] == 0 && pn[k + 56] == 2) {  //斜左 22202
                    jqn[k + 42] = jqn[k + 42] + 9000;
                }
            }

            if (j < 12 && i < 12) {
                if (pn[k] == 2 && pn[k + 16] == 0 && pn[k + 32] == 2 && pn[k + 48] == 2 && pn[k + 64] == 2) {  //右斜 20222
                    jqn[k + 16] = jqn[k + 16] + 9000;
                }
                if (pn[k] == 2 && pn[k + 16] == 2 && pn[k + 32] == 0 && pn[k + 48] == 2 && pn[k + 64] == 2) {  //右斜 22022
                    jqn[k + 32] = jqn[k + 32] + 9000;
                }
                if (pn[k] == 2 && pn[k + 16] == 2 && pn[k + 32] == 2 && pn[k + 48] == 0 && pn[k + 64] == 2) {  //右斜 22202
                    jqn[k + 48] = jqn[k + 48] + 9000;
                }
            }

            //****************************
            //以下是黑棋估权计分
            //独子 左右上下 二对角 八方
            if (pn[k] == 1) {
                if (pn[k - 1] == 0) jqn[k - 1] = jqn[k - 1] + 20;
                if (pn[k + 1] == 0) jqn[k + 1] = jqn[k + 1] + 20;
                if (pn[k - 15] == 0) jqn[k - 15] = jqn[k - 15] + 20;
                if (pn[k + 15] == 0) jqn[k + 15] = jqn[k + 15] + 20;
                if (pn[k + 14] == 0) jqn[k + 14] = jqn[k + 14] + 20;
                if (pn[k + 16] == 0) jqn[k + 16] = jqn[k + 16] + 20;
                if (pn[k - 14] == 0) jqn[k - 14] = jqn[k - 14] + 20;
                if (pn[k - 16] == 0) jqn[k - 16] = jqn[k - 16] + 20;
            }//pn
            //连二
            if (pn[k] == 1 && pn[k + 1] == 1) {  //左右
                if (pn[k - 1] == 0) jqn[k - 1] = jqn[k - 1] + 500;
                if (pn[k + 2] == 0) jqn[k + 2] = jqn[k + 2] + 500;
            }
            if (pn[k] == 1 && pn[k + 15] == 1) {  //上下
                if (pn[k - 15] == 0) jqn[k - 15] = jqn[k - 15] + 500;
                if (pn[k + 30] == 0) jqn[k + 30] = jqn[k + 30] + 500;
            }
            if (pn[k] == 1 && pn[k + 14] == 1) {  //左对角
                if (pn[k - 14] == 0) jqn[k - 14] = jqn[k - 14] + 500;
                if (pn[k + 28] == 0) jqn[k + 28] = jqn[k + 28] + 500;
            }
            if (pn[k] == 1 && pn[k + 16] == 1) {   //右对角
                if (pn[k - 16] == 0) jqn[k - 16] = jqn[k - 16] + 500;
                if (pn[k + 32] == 0) jqn[k + 32] = jqn[k + 32] + 500;
            }
            //嵌三   02020
            if (pn[k] == 1 && pn[k + 1] == 0 && pn[k + 2] == 1) {  //左右
                jqn[k + 1] = jqn[k + 1] + 500;
            }
            if (pn[k] == 1 && pn[k + 15] == 0 && pn[k + 30] == 1) {  //上下
                jqn[k + 15] = jqn[k + 15] + 500;
            }
            if (pn[k] == 1 && pn[k + 14] == 0 && pn[k + 28] == 1) {//左对角
                jqn[k + 14] = jqn[k + 14] + 500;
            }
            if (pn[k] == 1 && pn[k + 16] == 0 && pn[k + 32] == 1) {//右对角
                jqn[k + 16] = jqn[k + 16] + 500;
            }

            //三连，眠三12220  02221 逢三必堵
            if (pn[k] == 1 && pn[k + 1] == 1 && pn[k + 2] == 1) {  //左右
                if (pn[k - 1] == 0) jqn[k - 1] = jqn[k - 1] + 3000;
                if (pn[k + 3] == 0) jqn[k + 3] = jqn[k + 3] + 3000;
            }
            if (pn[k] == 1 && pn[k + 15] == 1 && pn[k + 30] == 1) {  //上下
                if (pn[k - 15] == 0) jqn[k - 15] = jqn[k - 15] + 3000;
                if (pn[k + 45] == 0) jqn[k + 45] = jqn[k + 45] + 3000;
            }

            if (pn[k] == 1 && pn[k - 14] == 1 && pn[k - 28] == 1) {//左对角
                if (pn[k + 14] == 0) jqn[k + 14] = jqn[k + 14] + 3000;
                if (pn[k - 42] == 0) jqn[k - 42] = jqn[k - 42] + 3000;
                if (pn[k + 2] == 0) jqn[k + 2] = jqn[k + 2] + 3050;
                if (pn[k - 30] == 0) jqn[k - 30] = jqn[k - 30] + 3050;
            }    //破梅花阵
            if (pn[k] == 1 && pn[k + 16] == 1 && pn[k + 32] == 1) {//右对角
                if (pn[k - 16] == 0) jqn[k - 16] = jqn[k - 16] + 3000;
                if (pn[k + 48] == 0) jqn[k + 48] = jqn[k + 48] + 3000;
                if (pn[k + 2] == 0) jqn[k + 2] = jqn[k + 2] + 3050;
                if (pn[k + 30] == 0) jqn[k + 30] = jqn[k + 30] + 3050;
            }    //破梅花阵

            //三连，活三  01110  逢三必堵
            if (pn[k - 1] == 0 && pn[k] == 1 && pn[k + 1] == 1 && pn[k + 2] == 1 && pn[k + 3] == 0) {  //左右
                if (pn[k - 1] == 0) jqn[k - 1] = jqn[k - 1] + 3300;
                if (pn[k + 3] == 0) jqn[k + 3] = jqn[k + 3] + 3300;
            }

            if (pn[k - 15] == 0 && pn[k] == 1 && pn[k + 15] == 1 && pn[k + 30] == 1 && pn[k + 45] == 0) {  //上下
                if (pn[k - 15] == 0) jqn[k - 15] = jqn[k - 15] + 3300;
                if (pn[k + 45] == 0) jqn[k + 45] = jqn[k + 45] + 3300;
            }

            if (pn[k - 14] == 0 && pn[k] == 1 && pn[k + 14] == 1 && pn[k + 28] == 1 && pn[k + 42] == 0) {//左对角
                if (pn[k - 14] == 0) jqn[k - 14] = jqn[k - 14] + 3300;
                if (pn[k + 42] == 0) jqn[k + 42] = jqn[k + 42] + 3300;
            }

            if (pn[k - 16] == 0 && pn[k] == 1 && pn[k + 16] == 1 && pn[k + 32] == 1 && pn[k + 48] == 0) {//右对角
                if (pn[k - 16] == 0) jqn[k - 16] = jqn[k - 16] + 3300;
                if (pn[k + 48] == 0) jqn[k + 48] = jqn[k + 48] + 3300;
            }

            //嵌四 010110   011010   必杀点 +3500
            if (pn[k - 1] == 0 && pn[k] == 1 && pn[k + 1] == 0 && pn[k + 2] == 1 && pn[k + 3] == 1 && pn[k + 4] == 0) {  //左右
                jqn[k + 1] = jqn[k + 1] + 3500;
            }
            if (pn[k - 1] == 0 && pn[k] == 1 && pn[k + 1] == 1 && pn[k + 2] == 0 && pn[k + 3] == 1 && pn[k + 4] == 0) {  //左右
                jqn[k + 2] = jqn[k + 2] + 3500;
            }

            if (pn[k - 15] == 0 && pn[k] == 1 && pn[k + 15] == 0 && pn[k + 30] == 1 && pn[k + 45] == 1 && pn[k + 60] == 0) {  //上下
                jqn[k + 15] = jqn[k + 15] + 3500;
            }
            if (pn[k - 15] == 0 && pn[k] == 1 && pn[k + 15] == 1 && pn[k + 30] == 0 && pn[k + 45] == 1 && pn[k + 60] == 0) {  //上下
                jqn[k + 30] = jqn[k + 30] + 3500;
            }

            if (pn[k - 14] == 0 && pn[k] == 1 && pn[k + 14] == 0 && pn[k + 28] == 1 && pn[k + 42] == 1 && pn[k + 56] == 0) {  //斜左
                jqn[k + 14] = jqn[k + 14] + 3500;
            }
            if (pn[k - 14] == 0 && pn[k] == 1 && pn[k + 14] == 1 && pn[k + 28] == 0 && pn[k + 42] == 1 && pn[k + 56] == 0) {  //斜左
                jqn[k + 28] = jqn[k + 28] + 3500;
            }

            if (pn[k - 16] == 0 && pn[k] == 1 && pn[k + 16] == 0 && pn[k + 32] == 1 && pn[k + 48] == 1 && pn[k + 64] == 0) {  //右斜
                jqn[k + 16] = jqn[k + 16] + 3500;
            }
            if (pn[k - 16] == 0 && pn[k] == 1 && pn[k + 16] == 1 && pn[k + 32] == 0 && pn[k + 48] == 1 && pn[k + 64] == 0) {  //右斜
                jqn[k + 32] = jqn[k + 32] + 3500;
            }

            //活四冲四 此是必杀点 211110  011112   +6000
            //黑有此白必堵，此是必杀点 如白无连五则必应 
            if (pn[k] == 1 && pn[k + 1] == 1 && pn[k + 2] == 1 && pn[k + 3] == 1) {  //左右
                if (pn[k - 1] == 0) jqn[k - 1] = jqn[k - 1] + 7000;
                if (pn[k + 4] == 0) jqn[k + 4] = jqn[k + 4] + 7000;
            }

            if (pn[k] == 1 && pn[k + 15] == 1 && pn[k + 30] == 1 && pn[k + 45] == 1) {  //上下
                if (pn[k - 15] == 0) jqn[k - 15] = jqn[k - 15] + 7000;
                if (pn[k + 60] == 0) jqn[k + 60] = jqn[k + 60] + 7000;
            }
            if (pn[k] == 1 && pn[k - 14] == 1 && pn[k - 28] == 1 && pn[k - 42] == 1) {//左对角
                if (pn[k + 14] == 0) jqn[k + 14] = jqn[k + 14] + 7000;
                if (pn[k - 56] == 0) jqn[k - 56] = jqn[k - 56] + 7000;
            }

            if (pn[k] == 1 && pn[k + 16] == 1 && pn[k + 32] == 1 && pn[k + 48] == 1) {//右对角
                if (pn[k - 16] == 0) jqn[k - 16] = jqn[k - 16] + 7000;
                if (pn[k + 64] == 0) jqn[k + 64] = jqn[k + 64] + 7000;
            }

            //嵌五 10111  11011  11101   +6000
            //此是必杀点 如白无连五则必应 
            if (pn[k] == 1 && pn[k + 1] == 0 && pn[k + 2] == 1 && pn[k + 3] == 1 && pn[k + 4] == 1) {  //左右 10111
                jqn[k + 1] = jqn[k + 1] + 7000;
            }
            if (pn[k] == 1 && pn[k + 1] == 1 && pn[k + 2] == 0 && pn[k + 3] == 1 && pn[k + 4] == 1) {  //左右 11011
                jqn[k + 2] = jqn[k + 2] + 7000;
            }
            if (pn[k] == 1 && pn[k + 1] == 1 && pn[k + 2] == 1 && pn[k + 3] == 0 && pn[k + 4] == 1) {  //左右 11101
                jqn[k + 3] = jqn[k + 3] + 7000;
            }

            if (pn[k] == 1 && pn[k + 15] == 0 && pn[k + 30] == 1 && pn[k + 45] == 1 && pn[k + 60] == 1) {  //上下 10111
                jqn[k + 15] = jqn[k + 15] + 7000;
            }
            if (pn[k] == 1 && pn[k + 15] == 1 && pn[k + 30] == 0 && pn[k + 45] == 1 && pn[k + 60] == 1) {  //上下 11011
                jqn[k + 30] = jqn[k + 30] + 7000;
            }
            if (pn[k] == 1 && pn[k + 15] == 1 && pn[k + 30] == 1 && pn[k + 45] == 0 && pn[k + 60] == 1) {  //上下 11101
                jqn[k + 45] = jqn[k + 45] + 7000;
            }

            if (pn[k] == 1 && pn[k + 14] == 0 && pn[k + 28] == 1 && pn[k + 42] == 1 && pn[k + 56] == 1) {  //斜左 10111
                jqn[k + 14] = jqn[k + 14] + 7000;
            }
            if (pn[k] == 1 && pn[k + 14] == 1 && pn[k + 28] == 0 && pn[k + 42] == 1 && pn[k + 56] == 1) {  //斜左 11011
                jqn[k + 28] = jqn[k + 28] + 7000;
            }
            if (pn[k] == 1 && pn[k + 14] == 1 && pn[k + 28] == 1 && pn[k + 42] == 0 && pn[k + 56] == 1) {  //斜左 11101
                jqn[k + 42] = jqn[k + 42] + 7000;
            }

            if (pn[k] == 1 && pn[k + 16] == 0 && pn[k + 32] == 1 && pn[k + 48] == 1 && pn[k + 64] == 1) {  //右斜 10111
                jqn[k + 16] = jqn[k + 16] + 7000;
            }
            if (pn[k] == 1 && pn[k + 16] == 1 && pn[k + 32] == 0 && pn[k + 48] == 1 && pn[k + 64] == 1) {  //右斜 11011
                jqn[k + 32] = jqn[k + 32] + 7000;
            }
            if (pn[k] == 1 && pn[k + 16] == 1 && pn[k + 32] == 1 && pn[k + 48] == 0 && pn[k + 64] == 1) {  //右斜 11101
                jqn[k + 48] = jqn[k + 48] + 7000;
            }

        }
    }    //test i , j   pn(225) 棋盘点位

    //******************************
    //测试：显示加权计分情况，最高分白下子
    if (isDo == 0) return;
    cs.SetTextSize(16);
    cs.SetTextStyle(0);
    cs.SetColor(255, 0, 150, 0);
    for (i = 1; i <= 225; i++) {    //test scan
        if (jqn[i] != 0) {
            //print i,"  qn= ",jqn[i] ;    //测试
            s = intToString(jqn[i]);
            dx = (i - (i / 15 * 15)) * 40;
            dy = (i / 15) * 40 + 40;
            if (dx == 0) { dx = 15 * 40; dy = dy - 40; }
            cs.DrawText(s, dx, dy);  //draw jqn(i)
        }
    }

    //计算最高分
    jqf = 0;
    for (i = 1; i <= 225; i++) {
        k = jqn[i];
        if (k > jqf) { jqf = k; jqfn = i; }
    } //计算最高分

    sn = jqfn;     //计权最高分点位转坐标
    if (dn == 1) {
        if (gn == 1) sn = 98;
        if (gn == 2) sn = 97;
        if (gn == 3) sn = 99;
    }
    //   print " sn= ",jqfn ," jqf= ",jqf ;
    dx = (sn - (sn / 15 * 15)) * 40;
    dy = (sn / 15) * 40 + 40;
    if (dx == 0) { dx = 15 * 40; dy = dy - 40; }
    cs.SetColor(255, 250, 250, 0);
    cs.DrawCircle(dx, dy, 5);  //标记下子点
    cs.Update();
    //  sleep (500) ;
    n = sn;      //下子点号sn转换为n,  draw board
    px = dx; py = dy;    //board ()标记下子点
    //**** AI 走子 ********************** 
}//testAIq ()

function black_do() {    //黑棋下子
    pn[n] = 1;
    s6 = "白棋选子";
    row = 15 - (n / 15);
    col = (n - (n / 15 * 15));
    if (col == 0) { col = 15; row = row + 1; }
    swapabc();   //return ss
    cordp = " B   " + intToString(n);    //走子记录
    cordp1 = " B  " + ss + intToString(row);
    if (cordp != ss2) {    //不重复记录
        dn = dn + 1;       //print dn;   
        //   print dn," ",cordp,"    " , ss,row ;  //打印记录
        ss2 = cordp;
        dwn[dn] = n;    //print play number
        fudat[dn] = n; fusum = dn;  //复盘数据                           
        board();
    }
    testAIq();     //test AI 计权白子点位下子 **

    if (mode == 1) {     //人机模式下子
        white_do();
    }    // AI Do  白下子
}//black_do ()

function white_do() {    //白棋下子
    if (isDo == 0) return;
    pn[n] = 2;
    s6 = "黑棋选子";
    row = 15 - (n / 15);
    col = (n - (n / 15 * 15));
    if (col == 0) { col = 15; row = row + 1; }
    swapabc();   //return ss
    cordp = " W  " + intToString(n);     //走子记录
    cordp1 = "W  " + ss + intToString(row);
    if (cordp != ss2) {
        dn = dn + 1;
        //  print dn," ",cordp,"    " , ss,row ;  //打印记录
        ss2 = cordp;
        dwn[dn] = n;    //print play number
        fudat[dn] = n; fusum = dn;  //复盘数据
        board();
    }
    if (jsset == 1) restrict_move();    //禁手设置
    //scan restricted move and draw mark
}//white_do ()
